<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>修改密码</title>
		<link rel="stylesheet" href="css/change_password.css">
		<script src="js/jquery.min.js"></script>
		<script src="js/my.js"></script>
	</head>
	<body id="main">
		<div id="find">
			<div id="find01">
				原密码:<input type="password" name="password" id="password"/>
			</div>
			<div id="find02">
				新密码:<input type="password" name="newpassword" id="newpassword"/>
			</div>
			<div id="find03">
				确认新密码:<input type="password" name="confpassword" id="confpassword"/>
			</div>
			<div id="find04">
				<input type="button" name="confirm" id="confim" value="确认" />
			</div>
			<div id="find05">
				<input type="button" name="chongzhi" id="chongzhi" value="重置" />
			</div>
		</div>
	</body>
	<script src="js/yz.js" charset="utf-8"></script>
	<script>
		$("#confim").click(function (){
			var name=window.sessionStorage.getItem('username');
			$.ajax({
				url:host+"/dealer/checkAndUpdatePassword",
				type:"get",
				async:true,
				dataType:"json",
				data:{
					"username":name,
					"password":$("#password").val(),
					"newPassword":$("#newpassword").val(),
					"confirm":$("#confpassword").val(),
				},
				success(res){
					if (res['code']==0){
						alert(res['message']);
						$("#password").val("");
						$("#newpassword").val("");
						$("#confpassword").val("");
						window.open("./login.html");
						location.href="about:blank";
						window.close();
						window.sessionStorage.clear();
					}else {
						alert(res['message']);
					}
				}
			})
		})

		$("#chongzhi").click(function () {
			$("#password").val("");
			$("#newpassword").val("");
			$("#confpassword").val("");
		})
	</script>
</html>
